package com.yidu.KuangJia.controller;

import com.yidu.BusinessData.entity.Fund;
import com.yidu.KuangJia.entity.Righty;
import com.yidu.KuangJia.service.RightService;
import com.yidu.KuangJia.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class LoginController {
    @Autowired
    private UserService userService;
    @Autowired
    private RightService rightService;

    @RequestMapping("/selectLogin")
    public int  selectLogin(String userName, String userPwd, Fund fund, HttpServletRequest req,Model model){
        System.out.println("进入了登录服务类");
        System.out.println(fund);
        HttpSession session = req.getSession();
        session.setAttribute("fundId",fund.getFundId());
        session.setAttribute("cashId","C20220628001");
        session.setAttribute("userName",userName);
        int i = userService.selectUser(userName,userPwd);
        System.out.println("i="+i);
        List<Righty> rightyList = rightService.selectRighty();
        model.addAttribute("rightyList",rightyList);
        return i;
    }
}
